<!DOCTYPE HTML>
<html>
<!--_meta 作为公共模版分离出去-->
{include file="common/_meta"}
<!--/meta 作为公共模版分离出去-->

<body>
<!--_header 作为公共模版分离出去-->
{include file="common/_header"}
<!--/_header 作为公共模版分离出去-->
<!--_menu 作为公共模版分离出去-->
{include file="common/_menu"}
<!--/_menu 作为公共模版分离出去-->

<section class="Hui-article-box">
{include file="common/_nav"}  
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="cl pd-5 bg-1 bk-gray"> 
                <span class="l"> 
                        <a href="javascript:;" onclick="delAll()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
                        <a class="btn btn-primary radius" href="{:url('add')}"><i class="Hui-iconfont">&#xe600;</i> 添加权限</a> 
                </span> 
                <span class="r">共有数据：<strong>{$counts}</strong> 条</span> 
            </div>
            <div class="mt-10">
            <table class="table table-border table-bordered table-hover table-bg">
                <thead>
                    <tr class="text-c">
                        <th width="25"><input type="checkbox" value="" name=""></th>
                        <th width="40">ID</th>
                        <th width="10%">权限名</th>
                        <th width="15%">控制器/方法名</th>
                        <th width="20%">路径</th>
                        <th width="30%">描述</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {foreach $data as $val}
                    <tr class="text-c">
                        <td><input type="checkbox" value="{$val.id}" name="checkbox[]"></td>
                        <td>{$val.id}</td>
                        <td>{$val.permi_name}</td>
                        <td>{$val.permi_method}</td>
                        <td>{eq name="val.pid" value="0"}{$val.permi_method}/index{else}{$val.pid|model('Permission')->getPermitCrtl}/{$val.permi_method}{/eq}</td>
                        <td>{$val.description}</td>
                        <td> 
                            <a title="编辑" href="{:url('edit','id='.$val.id)}"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
                            <a title="删除" href="javascript:;" onclick="permiDel(this,'{$val.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                        </td>
                    </tr>
                    {/foreach}
                </tbody>
            </table>
            </div>
            <div class="cl pd-5 bg-1 bk-gray mt-20  pagin">
                    <div class="message">共<i class="blue">{$pages}</i>页 | <i class="blue">{$counts}</i>条记录, 当前显示第&nbsp;<i class="blue nowpage"></i>页</div>
                    {$data->render()}
            </div>
        </article>
    </div>
</section>

<!--_footer 作为公共模版分离出去-->
{include file="common/_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">
var nowpage=$('.active').children('span').text();
nowpage = nowpage=="" ? 1 : nowpage;
$(".nowpage").html(nowpage);

function permiDel(obj,id){
    layer.confirm('确认要删除吗？',function(index){
        $.post('{:url("del")}',{'id':id},function(data){
            if(data.status==1){
                layer.msg(data.msg,{icon:1,time:1000});
                $(obj).parents("tr").remove();
            }else{
                layer.msg(data.msg,{icon:5,time:1000});
            }
        },'json')
    });
}

function delAll(){
    var checkbox = $('.text-c input[name="checkbox[]"]') ;
    var ids = new Array();
    checkbox.each(function(x){
        if(this.checked){
            ids.push(this.value);
        }
    });
    layer.confirm('确认要删除吗？',function(index){
        $.post('{:url("del")}',{'id':ids},function(data){
            if(data.status==1){
                layer.msg(data.msg,{icon:1,time:1000});
                checkbox.each(function(x){
                    if(this.checked){
                        $(this).parents("tr").remove();
                    }
                });
            }else{
                layer.msg(data.msg,{icon:5,time:1000});
            }
        },'json')
    });
}
</script>
<!--请在上方写此页面业务相关的脚本--> 
</body>
</html>